/**
 * Created by dev-001 on 2017/2/28.
 * 年级
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const GradeSchema = new Schema({
    name: String,//年级状态，如初一，初二，初三
    school: {
        type: ObjectId,
        ref: 'School'
    },
    group: {
        type: ObjectId,
        ref: 'Group'
    },
    textBook: {
        type: ObjectId,
        ref: 'TextBook'
    },
    level: Number, //0小学，1初中，2高中
    createdAt: Date,
    updatedAt: Date
});

GradeSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Grade', GradeSchema);